{include file="public/header" /}
<style>
    body{
        overflow: hidden;
    }
</style>

<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>优惠券</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>

    <form method="get" name="formSearch">
        <div class="ds-search-form">
            <dl>
                <dt>优惠券名称：</dt>
                <dd><input type="text" value="{$Request.get.store_name}" name="store_name" id="store_name" class="txt"
                           style="width:100px;"></dd>
            </dl>
            <dl>
                <dt>优惠券时间：</dt>
                <dd>
                    <input type="text" id="sdate" name="sdate" class="txt date" value="{$Request.get.sdate}">~
                    <input type="text" id="edate" name="edate" class="txt date" value="{$Request.get.edate}">
                </dd>
            </dl>
            <dl>
                <dt>类型：</dt>
                <dd>
                    <select name="state">
                        <option value="" selected>{$Think.lang.ds_please_choose}</option>
                        <option value="1"
                                {eq name="Request.get.state" value="1" }selected {/eq}>商城</option>
                        <option value="2" {eq name="Request.get.state" value="2" }selected {/eq}>服务</option>
                        <option value="3" {eq name="Request.get.state" value="3" }selected {/eq}>项目</option>
                    </select>
                </dd>
            </dl>
            <dl>
                <dt>启用状态：</dt>
                <dd>
                    <select name="recommend">
                        <option value="" selected>{$Think.lang.ds_please_choose}</option>
                        <option value="1" {eq name="Request.get.recommend" value="1" }selected {/eq}>启用</option>
                        <option value="2" {eq name="Request.get.recommend" value="2" }selected {/eq}>停用</option>
                    </select>
                </dd>
            </dl>
            <div class="btn_group">
                <a href="javascript:document.formSearch.submit();" class="btn" title="{$Think.lang.ds_query}">{$Think.lang.ds_query}</a>
                <a href="{:url('Voucher/index')}" class="btn btn-default" title="{$Think.lang.ds_cancel}">{$Think.lang.ds_cancel}</a>
            </div>
        </div>
    </form>
    <!-- 列表 -->
    <form id="list_form" method="post">
        <table class="ds-default-table">
            <thead>
            <tr class="thead">
                <th class="w24">序号</th>
                <th class="align-left"><span>优惠券名称</span></th>
              <!--  <th class="align-left"><span>品牌名称</span></th>-->
                <th class="align-left"><span>类型</span></th>
                <th class="align-center"><span>优惠券价格</span></th>
                <th class="align-center"><span>发行数量</span></th>
                <th class="align-center"><span>剩余数量</span></th>
                <th class="align-center"><span>限制条件</span></th>
                <th class="align-center"><span>优惠券开始时间</span></th>
                <th class="align-center"><span>优惠券结束时间</span></th>
                <th class="align-center"><span>状态</span></th>
                <th class="align-center"><span>优惠劵使用范围</span></th>
                <th class="align-center"><span>{$Think.lang.ds_handle}</span></th>
            </tr>
            </thead>
            <tbody id="treet1">
            {notempty name="vouchertemplate_list"}
            {foreach name="vouchertemplate_list" item="val" key="key"}
            <tr class="hover">
                <td><?php echo $key+1; ?></td>
                <td class="align-left">
                    <span>{$val.voucher_title}</span>
                </td>
              <!--  <td class="align-left">
                    <span>{$val.b_names}</span>
                </td>-->
                <td class="align-left">
                    <span><?php echo $vou_type_content[$val['vou_type']];?></span>
                </td>
                <td class="align-center"><span>{$val.voucher_price}</span></td>
                <td class="align-center"><span>{$val.count}</span></td>
                <td class="align-center"><span>{$val.surplus_count}</span></td>
                <td class="align-center"><span>满{$val.voucher_limit}元可以使用</span></td>
                <td class="align-center"><span>{$val.voucher_startdate|date="Y-m-d",###}</span></td>
                <td class="align-center"><span>{$val.voucher_enddate|date="Y-m-d",###}</span></td>
                <td class="align-center">
                    <span>
                    <?php if($val['status']==1){ echo '启用'; }else{ echo'停用'; } ?>
                    </span>
                </td>
                <td class="nowrap align-center">
                    <span><?php if(empty($val['vou_gcname'])){ echo '暂无'; }else{ echo $val['vou_gcname']; } ?></span>
                </td>
                <td class="nowrap align-center">
                    <a href="javascript:void(0);" onclick="voucher_setting_info({$val['voucher_id']});"
                       class="dsui-btn-view"><i class="iconfont"></i>查看</a>
                    <a href="{:url('Voucher/priceedit',['id'=>$val.voucher_id])}" class="dsui-btn-edit"><i
                            class="iconfont"></i>{$Think.lang.ds_edit}</a>
                    <a href="javascript:void(0);"
                       onclick="ds_ajaxget_confirm('{:url('Voucher/drop',['id'=>$val.voucher_id])}','确定要操作删除吗？');"
                       class="dsui-btn-del"><i class="iconfont"></i>删除</a>
                    <?php if($val['status']==1){ ?>
                    <a href="javascript:void(0);"
                       onclick="ds_ajaxget_confirm('{:url('Voucher/status',['id'=>$val.voucher_id,'status'=>0])}','确定要停用吗？');"
                       class="dsui-btn-edit"><i class="iconfont"></i>停用</a>
                    <?php }else{ ?>
                    <a href="javascript:void(0);"
                       onclick="ds_ajaxget_confirm('{:url('Voucher/status',['id'=>$val.voucher_id,'status'=>1])}','确定要启用吗？');"
                       class="dsui-btn-edit"><i class="iconfont"></i>启用</a>
                    <?php }?>


                </td>
            </tr>
            {/foreach}
            {else}
            <tr class="no_data">
                <td colspan="16">{$Think.lang.ds_no_record}</td>
            </tr>
            {/notempty}
            </tbody>
        </table>
        {$show_page}
    </form>

</div>
<script type="text/javascript" src="{$Think.ADMIN_SITE_ROOT}/js/jquery.edit.js" charset="utf-8"></script>
<script language="javascript">
    $(function () {
        $('#sdate').datepicker({dateFormat: 'yy-mm-dd'});
        $('#edate').datepicker({dateFormat: 'yy-mm-dd'});
    });

    //查看详情
    function voucher_setting_info(ids_str) {
        _uri = ADMINSITEURL + "/Voucher/voucher_setting_info?id=" + ids_str;
        dsLayerOpen(_uri, '查看详情', '800px', '600px');
    }
</script>